package com.guch.help.activity;

import static java.lang.Thread.sleep;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.LogUtils;
import com.guch.help.R;
import com.guch.help.utils.ProtectedSpUtils;

/**
 * 欢迎页面
 */
public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        try {
            sleep(1500);//使程序休眠一秒
            //  获取是否显示，如果已经显示过，则finish
            boolean isAlreadyShow = ProtectedSpUtils.getInstance(ProtectedSpUtils.DEEP_DEL_SP_NAME).getBoolean(ProtectedSpUtils.DEEP_DEL_FIRST_ENTER_KEY, false);
            LogUtils.i("SplashActivity", "---GST-----isAlreadyShow----" + isAlreadyShow);
            gotoMainActivity(isAlreadyShow ? NavigationActivity.class : IntroductionPageActivity.class);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    private void gotoMainActivity(Class<?> classes) {
        startActivity(new Intent(this, classes));
        finish();
    }

}
